/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PruebaCliente.java
 *
 * Created on 19/06/2011, 09:51:41 AM
 */

package GUI;
import Interfaz.InterfazControl;
import javax.swing.ImageIcon;
import Motor.Cliente;
import Persistencia.DAOClienteXML;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author yindri
 */
public class PruebaCliente extends javax.swing.JFrame {
	private InterfazControl laInterfaz;
    public PruebaCliente(InterfazControl laInterfaz) {
		this.laInterfaz=laInterfaz;
        initComponents();
		this.setLocationRelativeTo(null); // Cambiar icono de java en ventana
        this.setIconImage(new ImageIcon("src/imagenes/marketplus2.png").getImage());
	}
	

    /** Creates new form VentanaListaEstudiantes */

     public PruebaCliente ()
	 {
        initComponents();
         this.setLocationRelativeTo(null);
     //    this.setIconImage(new ImageIcon("src/imagenes/stuIconN.png").getImage());
         this.setResizable(false);
         this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		 llenarTabla();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tablaPrueba = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        tablaPrueba.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Nombre", "Apellido", "Cedula"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tablaPrueba);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
   private void retornoActionPerformed(java.awt.event.ActionEvent evt)
   {
        // TODO add your handling code here:

        PruebaCliente control = new PruebaCliente();
        control.setLocationRelativeTo(null);
        control.setVisible(true);
        this.dispose();
    }


    private void llenarTabla()
	{


        String[] columna = {"Nombre", "Apellido", "Cedula" };
            DefaultTableModel dtm = new DefaultTableModel(null,columna);
            List<Cliente> Lista= laInterfaz.todosLosClientes();
            for (Cliente cli : Lista)
            {
				String[] row = { cli.getNombre(),cli.getApellido(),cli.getCedula() };
                dtm.addRow(row);
            }
			tablaPrueba.setModel(dtm);
    }
    /**
    * @param args the command line arguments
    */

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PruebaCliente().setVisible(true);
            }
        });



    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tablaPrueba;
    // End of variables declaration//GEN-END:variables

}
